package com.deepglint.source;

import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;

import java.util.Properties;

public class SourceTest_Kafka {
    public static void main(String[] args) throws Exception{
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        // 输出有序
        env.setParallelism(1);

        Properties properties = new Properties();
        properties.setProperty("bootstrap.servers","192.168.150.128:9092");
        DataStream<String> dataSet =
                env.addSource(new FlinkKafkaConsumer<>("sensor",
                        new SimpleStringSchema(),properties));

        dataSet.print();

        env.execute();
    }
}
